package com.chujian.framework.sync.handler;

import com.chujian.framework.sync.SyncData;
import com.chujian.framework.sync.SyncDataFactory;
import com.chujian.framework.sync.SyncConst;

import java.lang.reflect.Method;

// mybatis.IService.save
public class SaveHandler implements ISyncMethodHandler {

    @Override
    public String supportMethod() {
        return SyncConst.METHOD_SAVE;
    }

    @Override
    public SyncData creSyncData(Method method, Object[] args, Object returnValue, Object target) {
        // default boolean save(T entity)
        // 第一个参数为 insert 的参数
        Object obj = args[0];
        return SyncDataFactory.creSingleItemSyncData(SyncConst.CHANGE_TYPE_INSERT, target, obj);
    }
}
